|
|
|
|
|
|
|
Saving Toolbar Customizations at Runtime |
|
|
|
|
|
|
|
|
Once the Change event fires from the user changing the toolbar via the Customize Toolbar dialog box, the SaveToolbar method can be invoked. Heres some code I typically use to store the toolbars for each user: |
|
|
|
 |
|
|
|
|
Private Sub tbrMain_Change()
If Not mboolRestore Then
tbrMain.SaveToolbar "Toolbars-" & App.EXEName & _
"\" & Me.Name, _
App.EXEName, _
"MainToolbar"
End If
End Sub |
|
|
|
|
|
|
|
|
In the Change event of the toolbar, you invoke the SaveToolbar method. You should pass in three parameters that uniquely identify a particular area in the Registry where the toolbars will be stored. All the toolbar information is stored under the HKEY_CURRENT_USER key in the Registry. |
|
|
|
|
|
|
|
|
To emphasize that this entry is for toolbars, you might want to come up with a prefix such as Toolbars-, followed by the executable name. You then need to determine whether youll just be saving one toolbar for your application or several. If you have a lot of toolbars for different forms, you might want to add on the forms name in a subkey under Toolbars. This is what the second parameter is used for in the SaveToolbar method. The last parameter is for the subkey that will actually store the toolbar information. If you use these parameters for the SaveToolbar method, you can store as many toolbars for one application as you want. |
|
|
|
|
|
|
|
|
Restoring Toolbar Customizations at Runtime |
|
|
|
|
|
|
|
|
To restore a toolbar at runtime, you invoke the RestoreToolbar method on the toolbar during the Form_Activate event. You must use this method in the Form_Activate event and not in the Form_Load() event, because the toolbar is not initialized yet. In addition, you must invoke the Refresh method on the form after performing a Show method. This forces the toolbar to refresh itself, because it has a tendency not to refresh itself after a RestoreToolbar method. Heres the code you use in the Form_Activate event: |
|
|
|
 |
|
|
|
|
Private Sub Form_Activate()
' Restore Toolbar
mboolRestore = True |
|
|
|
|
|